<!--Pdf-->
<script type="text/javascript">
    function printPage(id)
    {

        var html="<fieldset>";
        html+= document.getElementById(id).innerHTML;
        html+="</fieldset>";

        var printWin = window.open('','','left=0,top=0,width=1,height=1,toolbar=0,scrollbars=0,status =0');
        printWin.document.write(html);
        printWin.document.close();
        printWin.focus();
        printWin.print();
        printWin.close();

        var html="<html>";
        html+="<head>";
        html+="<style type='text/css'>.mytable{border:1px solid #ccc;}.mytable tr{background-color:#008000;color:#FFF;}</style>";
        html+="<link rel='Stylesheet' type='text/css' href='<?php echo base_url(); ?>/css/report.css' media='print' />";
        html+="<link rel='Stylesheet' type='text/css' href='<?php echo base_url(); ?>/css/style_master.css' media='print' />";
        html+="<link rel='Stylesheet' type='text/css' href='<?php echo base_url(); ?>/css/jdate_picker/jquery.ui.all.css' media='print' />";
        html+="</head>";
        html+= document.getElementById(id).innerHTML;
        html+="</html>";
    }
</script>
<!--<script type="text/javascript">jQuery.noConflict()</script>-->
<link href="<?php echo base_url(); ?>css/report.css" rel="stylesheet" type="text/css" />  
<script type="text/javascript" language="javascript" src="<?php echo base_url() ?>media/js/jquery.js"></script>
<script type="text/javascript" language="javascript" src="<?php echo base_url() ?>media/js/jquery.dataTables.js"></script>
<script type="text/javascript" charset="utf-8">
    $(document).ready(function() {
        $('.example').dataTable();
    } );

</script>

<style type="text/css" title="currentStyle">
    @import "<?php echo base_url() ?>media/css/demo_page.css";
    @import "<?php echo base_url() ?>media/css/demo_table.css";
</style>

<fieldset id="month" style="margin: 0 auto;width:91.5%;height: auto;border: 1px #ccc solid; padding:20px;-moz-border-radius:10px;">
    <?php
    echo '<div style="float: right; border: 0px #ccc solid; margin-right: 15px;">';
    echo anchor('report/manager', img('images/user_images/cancel.png'));
    echo '</div>';
    ?>   
    <?php
    echo '<div id="subheader">';
    echo img(array('src' => 'images/NRY001_Logo-FINAL-master_01-horiz.jpg', 'alt' => 'logo', 'align' => 'left', 'width' => '150'));
    echo'</div>';
    echo '<center><strong style="font-size:20px;text-align:center;color:#5C9416;">Monthly Report</strong></center>';
    echo '<div style="float:right;color:#008000;width:25%; text-align:center;">View Yearly Report For  Year&nbsp;:' . '<b style="color:red;">  &nbsp;' . date("Y") . '</b>';
      ?>
        To print this report, Click here <a href="#"><img src="<?php echo base_url(); ?>/images/user_images/print.png" align="center" onclick="printPage('month')" id="image"  alt="Print yearly report" title="Print month report"/></a>
         </div> 
    <div class="Tcontrol" style="margin: 0 auto; float: right;width:70px;height: auto;border: 0px #ccc solid;text-align: center;font-size: 20px;color:#006600;">
    </div><br/><br/>
    <?php
//--------------this is define condition of sessesion------------------
    echo ' <div style="font-size:20px;width:50%;margin:auto;text-align:center;padding:10px 0px 10px 0px;color:#000;">Public Class</div>';
    ?>

    <!-- form of view report public monthly report-->
    <div class="task1" style="float: left; width: 100%;height: auto;border: 0px #ccc solid;padding: 5px;">
        <div class="full_width big"></div>
        <div id="demo">
            <table cellpadding="0" cellspacing="0" border="0"  id="mytable" class="example" width="100%">
                <thead>
                    <tr style="height:28px;background-color:#5C9416;color:#FFF;border:1px;text-align: center;font-weight: lighter;">
                        <th style="border:1px solid #ccc;">N&ordm</th>
                        <th style="border:1px solid #ccc;">Date</th>
                        <th style="border:1px solid #ccc;">Seller</th>
                        <th style="border:1px solid #ccc;">Items</th>
                        <th style="border:1px solid #ccc;">Quantity</th>
                        <th style="border:1px solid #ccc;">Unit Price</th>
                        <th style="border:1px solid #ccc;">Payment</th>
                        <th style="border:1px solid #ccc;">Credit</th>
                    </tr>
                </thead>
                <tbody>
                    <?php
                    $data = $this->db->query('SELECT *
FROM tbl_sale
INNER JOIN tbl_card ON tbl_card.car_id = tbl_sale.car_id
JOIN tbl_car_type ON tbl_car_type.car_type_id = tbl_card.car_type_id
WHERE month( sal_date ) = month( curdate( ) ) and car_type_name="public" ');
                    $j = 1;
                    foreach ($data->result() as $value) {
                        echo '<tr style="text-align:center;color:#000;font-weight: lighter;">
                        <td style="border:1px solid #ccc;">' . $j . '</td>
                        <td style="border:1px solid #ccc;">' . $value->sal_date . '</td>
                        <td style="border:1px solid #ccc;">' . $value->use_username . '</td>
                        <td style="border:1px solid #ccc;">' . $value->car_name . '</td>
                        <td style="border:1px solid #ccc;">' . $value->sal_quantity . '</td>
                        <td style="border:1px solid #ccc;">$' . $value->sal_price . '</td>
                        <td style="border:1px solid #ccc;">$' . ($value->sal_quantity * $value->sal_price) . '</td>
                        <td style="border:1px solid #ccc;">$' . (($value->sal_price * $value->sal_quantity) - ($value->sal_payment)) . '</td>
                        </tr>';
                        $j++;
                    }
                    ?>
                </tbody>
            </table>


        </div><br /><br />

        <?php
        $data_card = $this->db->query('SELECT sum(sal_quantity * sal_price) AS totals, SUM(sal_quantity * sal_price - sal_payment) AS credit
FROM tbl_sale
INNER JOIN tbl_card ON tbl_card.car_id = tbl_sale.car_id
JOIN tbl_car_type ON tbl_car_type.car_type_id = tbl_card.car_type_id
WHERE month( sal_date ) = month( curdate( ) ) and car_type_name="public" ');

        if ($data_card->num_rows() > 0) {
            echo '<table cellspacing="0" cellpadding = "5" style="float:right;text-align:center;" class="mytable">';
            echo '<tr style=" color: #FFF; background-color:#5C9416;">';
            echo '<th style="background-color:#5C9416;" height="20px" width="100px" ><center>Total</center></th>';
            echo '<th style="background-color:#5C9416;"height="20px" width="100px"><center>Credit</center></th>';
            echo '</tr>';
            echo '<tr>';
            foreach ($data_card->result() as $value) {
                echo '<td style="color:red;font-weight:Bold;"><center>$' . $value->totals . '</center></td>';
                echo '<td style="color:red;font-weight:Bold;text-align:center; width:20px;">$' . $value->credit . '</td>';
            }
            echo ' </tr>';
        }
        echo '</table>';
        ?>
        <div class="spacer"></div>
    </div>

    <!-- form of view report private monthly report-->
    <div style="margin: 0 auto;width: 100%;height: auto;border: 0px #ccc solid;text-align: center;font-size: 20px;color:#000;">Private Class and WorkShop/Retreat</div><br/>

    <div class="task1" style="float: left; width: 100%;height: auto;border: 0px #ccc solid;padding: 5px;">
        <div class="full_width big"></div>
        <div id="demo">
            <table cellpadding="0" cellspacing="0" border="0" id="mytable" class="example" width="100%">
                <thead>
                    <tr style="height:28px;background-color:#5C9416;color:#FFF;border:1px;text-align: center;font-weight: lighter;">
                        <th style="border:1px solid #ccc;">N&ordm</th>
                        <th style="border:1px solid #ccc;">Date</th>
                        <th style="border:1px solid #ccc;">Seller</th>
                        <th style="border:1px solid #ccc;">Items</th>
                        <th style="border:1px solid #ccc;">Quantity</th>
                        <th style="border:1px solid #ccc;">Unit Price</th>
                        <th style="border:1px solid #ccc;">Payment</th>
                        <th style="border:1px solid #ccc;">Credit</th>
                    </tr>
                </thead>
                <tbody>
                    <?php
                    $data_private = $this->db->query('SELECT *
FROM tbl_sale
INNER JOIN tbl_card ON tbl_card.car_id = tbl_sale.car_id
JOIN tbl_car_type ON tbl_car_type.car_type_id = tbl_card.car_type_id
WHERE month( sal_date ) = month( curdate( ) ) and car_type_name="private" ');

                    $j = 1;
                    foreach ($data_private->result() as $value) {
               echo '<tr style="text-align:center;color:#000;font-weight: lighter;">
                    <td  style="border:1px solid #ccc;">' . $j . '</td>
                    <td style="border:1px solid #ccc;">' . $value->sal_date . '</td>
                    <td style="border:1px solid #ccc;">' . $value->use_username . '</td>
                    <td style="border:1px solid #ccc;">' . $value->car_name . '</td>
                    <td style="border:1px solid #ccc;">' . $value->sal_quantity . '</td>
                    <td style="border:1px solid #ccc;">$' . $value->sal_price . '</td>
                    <td style="border:1px solid #ccc;">$' . ($value->sal_quantity * $value->sal_price) . '</td>
                    <td style="border:1px solid #ccc;">$' . (($value->sal_price * $value->sal_quantity) - ($value->sal_payment)) . '</td>
                    </tr>';
                      $j++;
                    }
                    ?>
                </tbody>
            </table><br /><br />
            <!--===========Query select Total price private card for view report===============-->
            <?php
            $data_cards = $this->db->query('SELECT sum(sal_quantity * sal_price) AS total,sum(sal_quantity * sal_price) AS totals, SUM(sal_quantity * sal_price - sal_payment) AS credit
FROM tbl_sale
INNER JOIN tbl_card ON tbl_card.car_id = tbl_sale.car_id
JOIN tbl_car_type ON tbl_car_type.car_type_id = tbl_card.car_type_id
WHERE month( sal_date ) = month( curdate( ) ) and car_type_name="private" ');
            if ($data_cards->num_rows() > 0) {
                echo '<table cellspacing="0" cellpadding = "5" border="0" style="float:right;text-align:center; " class="mytable">';
                echo '<tr style=" color: #FFF; background-color:#5C9416;">';
                echo ' <th  style="background-color:#5C9416;" height="20px" width="100px" ><center>Total</center></th>';
                echo '<th  style="background-color:#5C9416;"height="20px" width="100px"><center>Credit</center></th>';
                echo '</tr>';
                echo '</tr>';
                foreach ($data_cards->result() as $value) {
                    echo '<td style="color:red;font-weight:Bold;"><center>$' . $value->total . '</center></td>';
                    echo '<td style="color:red;font-weight:Bold;text-align:center;">$' . $value->credit . '</td>';
                }
                echo ' </tr>';
            }
            echo '</table>';
            ?>
            <!--===================End view report private monthly report//==========-->

            <!--//========== form of view report product Management monthly report//==========-->
            <?php
            $data_total_amount = $this->db->query('SELECT sum(sal_quantity * sal_price ) as total_amount , sum(sal_quantity * sal_price - sal_payment) AS credit_amount
FROM tbl_sale
INNER JOIN tbl_card ON tbl_card.car_id = tbl_sale.car_id
JOIN tbl_car_type ON tbl_car_type.car_type_id = tbl_card.car_type_id
WHERE month( sal_date ) = month(curdate( ) ) ');
            $data_product_amount = $this->db->query('SELECT sum(sal_quantity * sal_price ) AS total_pro,sum(sal_quantity * sal_price - sal_payment) AS credit
FROM tbl_sale
INNER JOIN tbl_product ON tbl_product.pro_id = tbl_sale.pro_id
JOIN tbl_pro_type ON tbl_pro_type.pro_type_id = tbl_product.pro_type_id
WHERE month( sal_date ) = month(curdate( ) ) ');
            $data_product_total = $this->db->query('SELECT sum(sal_quantity * sal_price ) AS total
FROM tbl_sale
INNER JOIN tbl_product ON tbl_product.pro_id = tbl_sale.pro_id
JOIN tbl_pro_type ON tbl_pro_type.pro_type_id = tbl_product.pro_type_id
WHERE month( sal_date ) = month(curdate( ) ) ');
            $data_product = $this->db->query('SELECT* FROM tbl_sale
INNER JOIN tbl_product ON tbl_product.pro_id = tbl_sale.pro_id
JOIN tbl_pro_type ON tbl_pro_type.pro_type_id = tbl_product.pro_type_id
WHERE month( sal_date ) = month(curdate( ) ) ');
            ?>

            <div style="margin: 0 auto;width: 100%;height: auto;border: 0px #ccc solid;text-align: center;font-size: 20px;color:#000; clear: both;">Product Monthly </div><br/>
            <div class="task1" style="float: left; width: 100%;height: auto;border: 0px #ccc solid;padding: 5px;">
                <div class="full_width big"></div>
                <div id="demo">
                    <table cellpadding="0" cellspacing="0" border="0" id="mytable" class="example" width="100%">
                        <thead>
                            <tr style="height:28px;background-color:#5C9416;color:#FFF;border:1px;text-align: center;font-weight: lighter;">
                                <th style="border:1px solid #ccc;">N&ordm</th>
                                <th style="border:1px solid #ccc;">Sell Date</th>
                                <th style="border:1px solid #ccc;">Seller</th>
                                <th style="border:1px solid #ccc;">Items</th>
                                <th style="border:1px solid #ccc;">Quantity</th>
                                <th style="border:1px solid #ccc;">Unit Price</th>
                                <th style="border:1px solid #ccc;">Payment</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php
                            $data_private = $this->db->query('SELECT *
                            FROM tbl_sale
                            INNER JOIN tbl_card ON tbl_card.car_id = tbl_sale.car_id
                            JOIN tbl_car_type ON tbl_car_type.car_type_id = tbl_card.car_type_id
                            WHERE month( sal_date ) = month( curdate( ) ) and car_type_name="private" ');

                            $j = 1;
                            foreach ($data_product->result() as $value) {
                                echo '<tr style="text-align:center;color:#000;font-weight: lighter;">
                            <td style="border:1px solid #ccc;">' . $j . '</td>
                            <td style="border:1px solid #ccc;">' . $value->sal_date . '</td>
                            <td style="border:1px solid #ccc;" >' . $value->use_username . '</td>
                            <td style="border:1px solid #ccc;">' . $value->pro_name . '</td>
                            <td  style="border:1px solid #ccc;">' . $value->sal_quantity . '</td>
                            <td style="border:1px solid #ccc;">$' . $value->sal_price . '</td>
                            <td style="border:1px solid #ccc;">$' . $value->sal_price * $value->sal_quantity . '</th>
                            </tr>';
                                $j++;
                            }
                            ?>
                        </tbody>
                    </table><br /><br />
                    <?php
                    foreach ($data_total_amount->result() as $rows) {
                        $tal = $rows->total_amount;
                        $credit_amount = $rows->credit_amount;
                    }
                    foreach ($data_product_amount->result() as $row) {
                        $total_pro = $row->total_pro;
                    }
                    $total_amount = $total_pro + $tal;
                    $totalall = $total_amount - $credit_amount;
                    echo '<tr style="background-color:#E8F6FE;">';
                    echo '<table cellspacing="0" cellpadding = "5" border="0" style="float:right;text-align:center; " class="mytable">';
                    echo '<tr style=" color: #FFF; background-color:#5C9416;">';
                    echo ' <th  style="background-color:#5C9416;"height="20px" width="100px" ><center>Total</center></th>';
                    echo '</tr>';
                    echo '</tr>';
                    foreach ($data_product_total->result() as $value) {
                        echo '<td style="color:red;font-weight:Bold;"><center>$' . $value->total . '</center></td>';
                    }
                    echo '</tr></table>';


                    foreach ($data_total_amount->result() as $rows) {
                        $tal = $rows->total_amount;
                        $credit_amount = $rows->credit_amount;
                    }
                    foreach ($data_product_amount->result() as $row) {
                        $total_pro = $row->total_pro;
                    }
                    $total_amount = $total_pro + $tal;
                    $totalall = $total_amount - $credit_amount;
                    echo '<br/><br/><br/><br/><table class="mytable" width="100%" cellspacing="0" cellpadding="0" border="0"><tr style="background-color:#E8F6FE;">';
                    echo ' <td colspan="6" style="text-align:right;font-size:16px;color:#008000;font-weight:Bold;width:90%;">Total Amount :<br/><br/>Total Credit :<br/><br/>Monthly Income :<br/><td>';
                    foreach ($data_product_total->result() as $value) {
                        echo '<p style="color:red;font-weight:Bold;" align="center">$' . $total_amount . '<br/><br/> $' . $credit_amount . '<br/><br/>$' . $totalall . '</p>';
                    }
                    echo '</table>';
                    echo '</fieldset>';
                    echo '</div>';
                    ?>
                </div>
                    <div class="spacer"></div>
                    <h1>&nbsp;</h1>



